# -*- coding: utf-8 -*-

from django.conf.urls import url
from django.urls import include
from django.views.generic import RedirectView

from web.views import account, home, project, manage, setting, issues, dashboard
from web.views import wiki
from web.views import file
from web.views import statistics


urlpatterns = [
    url(r'^$', RedirectView.as_view(url='/index/')),
    url(r'^register/$', view=account.register, name='register'),
    url(r'^login/sms/$', view=account.login_sms, name='login_sms'),
    url(r'^login/$', view=account.login, name='login'),
    url(r'^logout/$', view=account.logout, name='logout'),

    url(r'^price/$', view=home.price, name='price'),
    url(r'^payment/(?P<policy_id>\d+)/$', view=home.payment, name='payment'),
    url(r'^pay/$', view=home.pay, name='pay'),
    url(r'^pay/notify$', view=home.pay_notify, name='pay_notify'),

    url(r'^image/code/$', view=account.image_code, name='image_code'),
    url(r'^send/sms/$', view=account.send_sms, name='send_sms'),
    
    url(r'^index/$', view=home.index, name='index'),
    
    # 项目列表
    url(r'^project/list/$', view=project.project_list, name='project_list'),
    # /project/star/my/1
    # /project/star/join/1
    url(r'^project/star/(?P<project_type>\w+)/(?P<project_id>\d+)/$', view=project.project_star, name='project_star'),
    url(r'^project/unstar/(?P<project_type>\w+)/(?P<project_id>\d+)/$', view=project.project_unstar, name='project_unstar'),
    
    # 项目管理
    # 因为路由里面还有很多子路由，所有再使用路由分发，简化路由
    # wiki管理
    url(r'^manage/(?P<project_id>\d+)/wiki/$', view=wiki.wiki, name='wiki'),
    url(r'^manage/(?P<project_id>\d+)/wiki/add/$', view=wiki.wiki_add, name='wiki_add'),
    url(r'^manage/(?P<project_id>\d+)/wiki/catalog/$', view=wiki.wiki_catalog, name='wiki_catalog'),
    url(r'^manage/(?P<project_id>\d+)/wiki/delete/(?P<wiki_id>\d+)/$', view=wiki.wiki_delete, name='wiki_delete'),
    url(r'^manage/(?P<project_id>\d+)/wiki/edit/(?P<wiki_id>\d+)/$', view=wiki.wiki_edit, name='wiki_edit'),
    url(r'^manage/(?P<project_id>\d+)/wiki/upload/$', view=wiki.wiki_upload, name='wiki_upload'),
    # 文件管理
    url(r'^manage/(?P<project_id>\d+)/file/$', view=file.file, name='file'),
    url(r'^manage/(?P<project_id>\d+)/file/delete/$', view=file.file_delete, name='file_delete'),
    url(r'^manage/(?P<project_id>\d+)/file/cos/credential/$', view=file.cos_credential, name='cos_credential'),
    url(r'^manage/(?P<project_id>\d+)/file/post/$', view=file.file_post, name='file_post'),
    url(r'^manage/(?P<project_id>\d+)/file/download/(?P<file_id>\d+)/$', view=file.file_download, name='file_download'),
    
    url(r'^manage/(?P<project_id>\d+)/setting/$', view=setting.setting, name='setting'),
    url(r'^manage/(?P<project_id>\d+)/setting/delete$', view=setting.delete, name='setting_delete'),
    
    # 问题管理
    url(r'^manage/(?P<project_id>\d+)/issues/$', view=issues.issues, name='issues'),
    url(r'^manage/(?P<project_id>\d+)/issues/detail/(?P<issues_id>\d+)/$', view=issues.issues_detail, name='issues_detail'),
    url(r'^manage/(?P<project_id>\d+)/issues/record/(?P<issues_id>\d+)/$', view=issues.issues_record, name='issues_record'),
    url(r'^manage/(?P<project_id>\d+)/issues/change/(?P<issues_id>\d+)/$', view=issues.issues_change, name='issues_change'),
    url(r'^manage/(?P<project_id>\d+)/issues/invite/url/$', view=issues.invite_url, name='invite_url'),

    # 概览
    url(r'^manage/(?P<project_id>\d+)/dashboard/$', view=dashboard.dashboard, name='dashboard'),
    url(r'^manage/(?P<project_id>\d+)/dashboard/issues/chart$', view=dashboard.issues_chart, name='issues_chart'),

    # 统计
    url(r'^manage/(?P<project_id>\d+)/statistics/$', view=statistics.statistics, name='statistics'),
    url(r'^manage/(?P<project_id>\d+)/statistics/priority/$', view=statistics.statistics_priority, name='statistics_priority'),
    url(r'^manage/(?P<project_id>\d+)/statistics/project/user/$', view=statistics.statistics_project_user, name='statistics_project_user'),

    # 邀请成员
    url(r'^invite/join/(?P<code>\w+)$', view=issues.invite_join, name='invite_join'),
]
